package com.itheima.reggie.utils;

import java.util.Random;

public class SendMessage {
    /**
     * 生成数字验证码
     * @param codeNum 验证码长度
     * @return
     */
    public static String createCode(int codeNum){
        String nums = "0123456789";
        StringBuilder code=new StringBuilder();
        Random random = new Random();
        for (int i=0; i < codeNum; i++) {
            code.append(nums.charAt(random.nextInt(nums.length())));
        }
        return code.toString();
    }

    public static void main(String[] args) {
        String code=SendMessage.createCode(4);
        System.out.println(code);
    }
}
